<?php
/**
 * Created by PhpStorm.
 * User: xuke
 * Date: 16/6/21
 * Time: 下午2:31
 */

namespace App\Http\Model;



class OrderGoods extends Base
{
    public $table = 'order_goods';

    public $timestamps = false;

    protected $guarded = [
        'id'
    ];
    
    public function goods()
    {
        return $this->hasOne(Goods::class, 'goods_id', 'goods_id');
    }
    
    public function skus()
    {
        return $this->hasOne(Goods::class, 'sku_id', 'sku_id');
    }
    
    public function setGoods($sku)
    {
        $this->goods_id = $sku->goods_id;
        $this->sku_id = $sku->sku_id;
        $this->goods_name = $sku->goods->name;
        $this->goods_sku_name = $sku->sku_name;
        $this->origin_price = $sku->price;
        $this->provider_id = $sku->provider_id;
        return $this;
    }

    public function setNum($num)
    {
        $this->goods_num = $num;
        return $this;
    }

    /**设置订单商品主订单号
     * @param $order_id
     */
    public function setOrderId($order_id)
    {
        $this->order_id = $order_id;
        return $this;
    }

    /**设置商品子订单号
     * @param $order_sub_id
     */
    public function setOrderSubId($order_sub_id)
    {
        $this->order_sub_id = $order_sub_id;
        return $this;
    }
}